package com.fang.strategy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author fanglingxiao
 * @version 1.0
 * @description TODO
 * @date 2022/4/22 4:36 下午
 **/
@Service
public class TestStrategy {

    @Autowired
    private StrategyFactory strategyFactory;

    public void addNum() {
        int calc = strategyFactory.create(CalcTypeEnum.ADD).calc(2, 2);
        System.out.println(calc);
    }

    public void subNum() {
        int calc = strategyFactory.create(CalcTypeEnum.SUB).calc(2, 2);
        System.out.println(calc);
    }
}
